Ext.define('AmpleHarvest.util.nestedJsonUi', 
{
    extend		: 'Ext.util.Observable',
    indentStyle	: 'margin: auto auto auto 10px',
    
    fieldsToIgnore : [],
    
	processObjectData : function(objectData) {
		var metadata = new Array();
		for(var item in objectData) {
			if(! Ext.Array.contains(this.fieldsToIgnore,item)) {
				metadata.push(this.processItem(item, objectData[item]));
			}
		}
		return metadata;
	},
	
	processItem : function (heading, data) {
		if(data instanceof Array) {
			return {
				title: heading,
				collapsible: true,
				bodyStyle: this.indentStyle,
				items: this.processArray(data)
			};
		} else if (data instanceof Object) {
			return {
				title: heading,
				collapsible: true,
				bodyStyle: this.indentStyle,
				items: this.processObjectData(data)
			};
		} else {
			return this.processField(heading,data);
		}
	},
	
	processArray : function(dataArray) {
		var displayItems = new Array();
		var count = 1;
		for(var item in dataArray) {
			displayItems.push(this.processItem(count++, dataArray[item])); 
		}

		return displayItems;
	},
	
	processField : function(labelName, data) {
		return {
			xtype: 'container',
			layout: 'hbox',
			items: [{
	        	xtype: 'label',
	        	text: labelName+':'
        	},{
	        	xtype: 'label',
	        	text: String(data),
	        	margin: '0 0 0 10'
        	}]
		};
	}
    
});